﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using EmailLib;
using CryptorLib;

public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            SendMail();

            DisplayMessage.Text = "Your comments after sending the mail";
            DisplayMessage.Visible = true;
            YourSubject.Text = "";
            YourEmail.Text = "";
            YourName.Text = "";
            Comments.Text = "";
        }
        catch(Exception ex)
        {
            DisplayMessage.Text = ex.ToString();
            DisplayMessage.Visible = true;
        }
    }

    protected void SendMail()
    {
        Email AspMailler = new Email("Nguyenthanhhoang7604119@gmail.com", "nguyenthanhhoang");

        string toAddress = "nguyenthanhhoang7604119@gmail.com";
        string subject = YourSubject.Text.ToString();
        string body = "From: " + YourEmail.Text + "\n";
        body += "Email: " + YourEmail.Text + "\n";
        body += "Subject: " + YourSubject.Text + "\n";
        body += "Question: \n" + Comments.Text + "\n";

        AspMailler.SendMail(toAddress, subject, body);
    }

    protected void btnCryptor_Click(object sender, EventArgs e)
    {
        Cryptor.Key = "12345";  
        EncryptedString.Text = Cryptor.Encrypt(Input.Text);
        DecryptedString.Text = Cryptor.Decrypt(EncryptedString.Text);
    }
}